<template>
        <div class="gold-shop-wrap">
            <van-nav-bar title="补贴明细" left-arrow fixed @click-left="onClickLeft" />
        <!-- <van-tabs v-model="active">
            <van-tab title="排队中"></van-tab>
            <van-tab title="已完成"></van-tab>
        </van-tabs> -->
        <div class="subsidy_title">
            <div class="subsidy_title_list" v-for="item, index in titleList" :key="index"
                :class="{ 'active': current === index }" @click="setCurrent(index)">{{ item.name }}</div>
        </div>
        <div class="subsidy_text">{{ tips }}</div>
        <!-- <div class="subsidy_text" v-if="current == 1">已有4000.00元完成了排队返利{{ tips }}</div> -->
        <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
            <div class="order_all" v-for="item,index in subsidyList" :key="index" :title="item">
                <div class="order_name_return">
                    <div class="order_name_left">{{ item.shop_name }}</div>
                    <!-- <div class="order_name_right">等待付款</div> -->
                </div>
                <div class="subsidy_lists">
                    <!-- <img src="../../assets/qr.jpg" alt=""> -->
                    <div class="order_goods">
                        <!-- <div class="order_goods_name">商品名称</div> -->
                        <div class="order_goods_sku">订单编号：{{ item.order_no }}</div>
                        <div class="order_goods_sku">下单时间：{{ item.payment_time }}</div>
                        <div class="order_goods_sku">实付金额：{{ item.payment }}</div>
                        <div class="order_goods_sku">花朵应兑换金额：{{ item.subsidy }}</div>
                        <div class="order_goods_sku">花朵已兑换金额：{{ item.received }}</div>
                        <div class="order_goods_sku" v-if="current == 1">完成时间：{{ item.complete_time }}</div>
                        <!-- <div class="order_goods_price">退款：<span>￥100</span></div> -->
                    </div>
                    <div class="subsidy_level" v-if="item.rank > 0">{{ item.rank }}</div>
                </div>
                <!-- <div class="order_total">共计10件商品 总计：800</div> -->
                <!-- <div class="order_pay">
                    <div class="order_pay_money"></div>
                    <div class="">
                        <van-button class="order_pay_btn" type="primary" size="small">删除记录</van-button>
                        <van-button class="order_pay_btn" type="primary" size="small" @click="ordeInfo">查看详情</van-button>
                    </div>
                </div> -->
            </div>
        </van-list>

    </div>
</template>
<script>
import { Dialog } from 'vant';
import {SUBSIDY_LIST} from '@/api/mine'
export default{
    data() {
        return {
            loading:false,
            finished: false,
            active:0,
            current:0,
            titleList:[
                {
                    id:0,
                    name:'排队中'
                },
                {
                    id:1,
                    name:'已完成'
                }
            ],
            subsidyList:[],
            page:1,
            pageSize:20,
            tips:""
        }
    },
    created() {
        // this.active=this.$route.query.id
    window.scrollTo(0, 0)

    },
    methods:{
        onClickLeft() {
            this.$router.back()
        },
        // 点击切换tab
        setCurrent(index) {
            this.current = index;
            // 数据请求
	        this.resetInit();
        },
    resetInit() {
        this.page = 1;
			  this.subsidyList = [];
			  this.finished = false;
			  this.loading = true;
			  this.onLoad()
    },
    onLoad() {
                 let params = {};
				params['page_num'] = this.page;
				params['page_size'] = this.pageSize;
				params['status'] = this.current;
                this.$http.get(SUBSIDY_LIST, {params:params})
				.then(res => {
				  const {
				    list
				  } = res.data;
                  this.tips=res.data.tip
				  if(list && list.length) {
				     this.page++;
				     this.subsidyList = this.subsidyList.concat(list);
				     // 加载状态结束
				     this.loading = false;
				     if(list.length < this.pageSize) {
				      this.finished = true;
				     }
				  }else {
				    this.finished = true;
				  }
				})
    },
}
}
</script>
<style lang="scss" scoped>
.gold-shop-wrap {
    min-height: 100vh;
    padding-top: 46px;
    background: #f5f5f5;

    ::v-deep .van-nav-bar .van-icon {
        color: #333333;
    }

    ::v-deep .van-nav-bar__arrow {
        font-size: 20px;
    }
}

.subsidy_title {
    // width: 95%;
    margin: 0 auto;
    // margin-top: 0.3rem;
    display: flex;
    font-size: 0.28rem;
    padding: .24rem .24rem 0 .24rem;
    box-sizing: border-box;
    background-color: #fff;

    .subsidy_title_list {
        margin-right: 0.4rem;
        // font-size: 0.28rem;
        position: relative;
        color: #666666;
        padding-bottom: 0.24rem;
    }

    .subsidy_title_list.active {
        color: #F32A23;
        font-weight: 500;

        &::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 2px; // 横杠的高度，可以根据需要调整
            background-color: #F32A23; // 红色横杠
        }

        /* 选中时黑色 */
    }


}

.subsidy_text {
    width: 95%;
    margin: 0 auto;
    margin-top: 0.2rem;
    font-size: 0.25rem;
    color: #999;
}

.order_all {
    width: 95%;
    margin: 0 auto;
    margin-top: 0.2rem;
    // border: 0.01rem solid #999;
    border-radius: 0.16rem;
    background: #fff;
    .order_name_return {
        display: flex;
        justify-content: space-between;
        font-size: 0.28rem;
        padding: 0.32rem;
        padding-bottom: 0;
        // border-bottom: 0.01rem solid #999;
        box-sizing: border-box;

        .order_name_left {
            font-weight: bold;
        }

        // &_right {
        //     font-size: 0.25rem;
        // }
    }

    .subsidy_lists {
        padding: 0.32rem;
        padding-top: 0.2rem;
        display: flex;
        justify-content: space-between;

        // img {
        //     width: 1.8rem;
        // }

        .order_goods {
            width: 70%;
            font-size: 0.24rem;
            line-height: 0.42rem;
            font-family: PingFangSC, PingFang SC;
            &_name {
                font-size: 0.3rem;
            }

            &_sku {
                color: #666666;
            }

            &_price {
                font-size: 0.3rem;
                // font-weight: bold;
                // display: flex;
                // justify-content: space-between;

                span:last-child {
                    font-weight: 500;
                    font-size: 0.25rem;
                    color: #999;
                }
            }
        }

        .subsidy_level {
            height: .6rem;
            border-radius: 15px;
            border: 0.02rem solid #F32A23;
            font-family: PingFangSC, PingFang SC;
            font-weight: 600;
            font-size: 0.28rem;
            color: #F32A23;
            line-height: .6rem;
            text-align: center;
            font-style: normal;
            padding: 0 .4rem;
            margin-top: 0.5rem;

        }
    }

    // .order_total {
    //     margin-left: 2.3rem;
    //     font-size: 0.25rem;
    //     margin-bottom: 0.2rem;
    // }

    // .order_pay {
    //     border-top: 0.01rem solid #999;
    //     display: flex;
    //     justify-content: space-between;
    //     padding: 0.2rem;

    //     .order_pay_money {
    //         font-size: 0.25rem;
    //         margin-top: 0.2rem;
    //     }

    //     .order_pay_btn {
    //         margin-left: 0.2rem;
    //     }
    // }
}
</style>
